<!DOCTYPE html>
<html>

<head>
    <title>Minimal 1.0 - Login Page</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="UTF-8" />

    <link rel="icon" type="image/ico" href="http://tattek.com/minimal/assets/images/favicon.ico" />
    <!-- Bootstrap -->
    <link href="css/vendor/bootstrap/bootstrap.min.css" rel="stylesheet">
    <link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
    <link rel="stylesheet" href="css/vendor/bootstrap-checkbox.css">
    <link href="css/minimal.css" rel="stylesheet">
    <style>
        .widths {
            width: 100%;
        }
    </style>
</head>

<body class="bg-1">
    <div id="wrap">
        <div class="row">
            <div id="content" class="col-md-12 full-page login">
                <div class="inside-block">
                    <img src="images/logo-big.png" alt="" class="logo">
                    <h1><strong>Blog</strong>管理后台登录</h1>
                    <form id="form-signin" class="form-signin">
                        <section>
                            <div class="input-group">
                                <input type="text" id="txtUserName" class="form-control" placeholder="请输入账号">
                                <div class="input-group-addon"><i class="fa fa-user"></i></div>
                            </div>
                            <div class="input-group">
                                <input type="password" id="txtUserPwd" class="form-control" placeholder="请输入密码">
                                <div class="input-group-addon"><i class="fa fa-key"></i></div>
                            </div>
                        </section>
                        <section class="controls">
                            <div class="checkbox check-transparent">
                                <input type="checkbox" value="1" id="remember" checked>
                                <label for="remember">记住账号</label>
                            </div>
                            <a href="#">忘记密码?</a>
                        </section>
                        <section class="log-in">
                            <button onclick="downLogin()" class="btn btn-greensea widths">登录</button>
                        </section>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <script src="js/jquery.min.js"></script>
    <script>
        function downLogin() {
            $.ajax({
                url: '/admin/login',
                method: 'post',
                dataType: 'json',
                data: {
                    userName: $('#txtUserName').val(),
                    userPwd: $('#txtUserPwd').val(),
                },
                success: function(res) {
                    if (res.status == 'y') {
                        window.location.href = '/admin/index'
                    } else {
                        alert(res.msg)
                    }
                },
                error: function(err) {
                    console.dir(err)
                    alert('服务器内部错误')
                }
            })
        }
    </script>
</body>

</html>